import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';

import '../main.dart';
import 'pages/search.dart';
import 'pages/prod.dart';

var routes = {
  "/": (context) => const MyHome(),
  "/search": (context) => const SearchPage(),
  "/prod": (context,{arguments}) => ProdPage(arguments: arguments),
};

var onGenerateRoute = (RouteSettings settings) {
  final String? name = settings.name;
  final Function? pageContentBuilder = routes[name];
  print(settings);
  print(settings.name);
  print(settings.arguments);
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = CupertinoPageRoute(builder: (context) {
        return pageContentBuilder(context, arguments: settings.arguments);
      });
      return route;
    } else {
      final Route route = CupertinoPageRoute(builder: (context) =>  pageContentBuilder(context));
      return route;
    }
  }
};
